package com.seu.algorithms.string;

/**
 * @author liangfeihu
 * @since 2019/2/22
 */
public class KeyValue implements Comparable {
    char ch;
    int count;

    public KeyValue() {
    }

    public KeyValue(char ch, int count) {
        this.ch = ch;
        this.count = count;
    }

    public char getCh() {
        return ch;
    }

    public void setCh(char ch) {
        this.ch = ch;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    @Override
    public int compareTo(Object obj) {
        if (obj instanceof KeyValue) {
            KeyValue kv = (KeyValue) obj;
            //return kv.count - this.count;
            if (kv.count - this.count == 0) {
                return kv.ch - this.ch;
            } else {
                return kv.count - this.count;
            }
        }
        return -1;
    }

}
